import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by forcht on 2018/4/26.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int[] a=new int[9997];
        for(int i=0;i<9997;i++){
            a[i]=scanner.nextInt();
        }
        Arrays.sort(a);
        int c=1;
        StringBuilder s=new StringBuilder();
        int i=0;
        while (i<9997){
            if(a[i]!=c){
                s.append(c);
            }else {
                i++;
            }
            c++;
        }
        BigInteger integer=new BigInteger(s.toString());
        System.out.println(integer.mod(new BigInteger("7")));
    }
}
